﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Procesos_Default" %>



<asp:Content ID="Content1" ContentPlaceHolderID="title" Runat="Server">
    Procesos
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderBreadcrumbs" Runat="Server">
    <ul>
        <li>Procesos</li>
    </ul>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceMain" Runat="Server">
    <h2 class="pagetitle">Procesos</h2>

    <div class="block">
        <asp:DropDownList ID="drpStatus" OnSelectedIndexChanged="drpStatus_SelectedIndexChanged" AutoPostBack="true" class="fields-filter" runat="server">
            <asp:ListItem Value="0">Todos</asp:ListItem>
            <asp:ListItem Selected="True" Value="1">Activos</asp:ListItem>
            <asp:ListItem Value="2">Inactivos</asp:ListItem>
        </asp:DropDownList>
        <asp:TextBox ID="txtSearchTerm" runat="server" class="fields-filter" style="margin-right:0px;" Text=""></asp:TextBox>
        <asp:ImageButton class="button-filter" runat="server" ID="btnSearch" AlternateText="Buscar" ToolTip="Buscar" 
            OnClick="btnSearch_Click" ImageUrl="~/img/search-icon.png"/>
    </div>
    <div class="column1-unit">
        <div class="container-add-button"><asp:LinkButton runat="server" ID="lnkAdd" CssClass="add-button" Text="Agregar" OnClick="lnkAdd_Click"></asp:LinkButton> </div>
        <asp:gridview ID="grid" runat="server" OnPageIndexChanging="grid_PageIndexChanging" OnSorting="grid_Sorting" DataSourceID="ds" 
            AutoGenerateColumns="False" EmptyDataText="No Existen Registros" AllowPaging="True" PageSize="10" DataKeyNames="Id" OnRowDataBound="grid_DataBound"
            BorderWidth="1" CellPadding="5" CellSpacing="0" AlternatingRowStyle-CssClass="row-alternation" OnRowCommand="grid_RowCommand">
                <Columns>  
                    <asp:TemplateField HeaderText="Nombre" HeaderStyle-CssClass="top" SortExpression="Name">
                        <ItemTemplate>    
                            <asp:Label ID="lblName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>     
                        </ItemTemplate>
                        
                    </asp:TemplateField> 
                    <asp:TemplateField HeaderText="Descripci&oacute;n" HeaderStyle-CssClass="top">
                        <ItemTemplate>    
                            <asp:Label ID="lblDescription" runat="server" Text='<%# Bind("Description") %>'></asp:Label>     
                        </ItemTemplate>
                        
                    </asp:TemplateField> 
                    <asp:TemplateField HeaderText="Muestra" HeaderStyle-CssClass="top">
                        <ItemTemplate>    
                            <a href='<%# GetImage(Eval("SampleImage").ToString()) %>' runat="server" id="aSample" rel="lightbox" title='<%# Bind("Name") %>'>
                                <asp:image runat="server" ID="imgSample" ToolTip="Muestra" ImageUrl='<%# GetImage(Eval("SampleImage").ToString()) %>' Width="140px" />
                            </a>   
                        </ItemTemplate>
                    </asp:TemplateField> 
                    <asp:TemplateField HeaderText="Estatus" SortExpression="isEnabled" HeaderStyle-CssClass="top" HeaderStyle-Width="50px" ItemStyle-CssClass="status" 
                        FooterStyle-CssClass="status">
                        <ItemTemplate>
                            <asp:ImageButton ID="ImageButton1" runat="server" AlternateText="Active" OnClientClick='<%# GetConfirmValue(Eval("Id").ToString(),"inactivo") %>' 
                                CommandArgument='<%#Eval("Id")%>' CommandName="Disable"  height="16px" ImageUrl="~/img/online-icon.png" ToolTip="Click para desactivar" 
                                Visible='<%# GetBoolValue(Eval("IsEnabled").ToString()) %>' />
                            <asp:ImageButton ID="ImageButton2" runat="server" AlternateText="Inactive" OnClientClick='<%# GetConfirmValue(Eval("Id").ToString(),"activo") %>' 
                                CommandArgument='<%#Eval("Id")%>' CommandName="Enable" height="16px" ImageUrl="~/img/invisible-icon.png" 
                                ToolTip="Click para activar" Visible='<%# !GetBoolValue(Eval("IsEnabled").ToString()) %>' />
                        </ItemTemplate>
                    </asp:TemplateField> 
                    <asp:TemplateField HeaderStyle-CssClass="top" HeaderStyle-Width="60px" ItemStyle-CssClass="status" FooterStyle-CssClass="status">
                        <HeaderTemplate>
                            Acciones
                        </HeaderTemplate>
                        <ItemTemplate> 
                            <asp:ImageButton ToolTip="Editar Proceso" ID="imgEdit" runat="server" CausesValidation="False" CommandName="Edit" 
                                ImageUrl="~/img/edit-icon.png" height="16px"></asp:ImageButton> 
                            <asp:ImageButton ID="ImageButton3" runat="server" AlternateText="Etapas" CausesValidation="false" CommandArgument='<%#Eval("Id")%>' CommandName="Etapas" 
                                height="16px" ImageUrl="~/img/configure-icon.png" ToolTip="Click para ver etapas" />
                            <asp:ImageButton ID="imgExport" runat="server" AlternateText="Exportar a Excel" CausesValidation="false" CommandArgument='<%#Eval("Id")%>' CommandName="Export" 
                                height="16px" ImageUrl="~/img/export-excel-icon.png" ToolTip="Click para exportar a excel" />
                        </ItemTemplate> 
                    </asp:TemplateField>
                </Columns>
            </asp:gridview>
            <asp:ObjectDataSource ID="ds" runat="server" TypeName="BLLProcess" SelectMethod="GetProcesses"
                EnablePaging="true" SelectCountMethod="GetProcessesCount" StartRowIndexParameterName="startRow"
                MaximumRowsParameterName="pageSize" SortParameterName="sortColumns" UpdateMethod="Update">        
                <SelectParameters>
                    <asp:SessionParameter  DefaultValue="" Name="sortExp" SessionField="sortExp" Type="String" />
                    <asp:SessionParameter DefaultValue="" Name="sortDirection" SessionField="sortDirection" Type="String" />
                    <asp:SessionParameter  DefaultValue="" Name="pageIndex" SessionField="pageIndex" Type="Int32" />
                    <asp:SessionParameter  DefaultValue="" Name="filterStatus" SessionField="filterStatus" Type="Int32" />
                    <asp:SessionParameter  DefaultValue="" Name="filterSearch" SessionField="filterSearch" Type="String" />
                </SelectParameters>              
            </asp:ObjectDataSource>
        </div>
        <asp:HiddenField runat="server" ID="hdnId" />
        <asp:Button runat="server" ID="lnkStatus" OnClick="lnkStatus_Click" style="display:none;"></asp:Button>
        <div id="dialog" style="display:none;"></div>
    <script type="text/javascript">
       
        function confirmMessage(title, message, id) {
            $("#dialog").html(message);
            $("#<%=hdnId.ClientID %>").val(id);
            $("#dialog").dialog(
                {
                    modal: true,
                    title: title,
                    buttons:
                    {
                        "Ok": function () {
                            $(this).dialog("close");
                            $("#<%=lnkStatus.ClientID %>").click();
                        },
                        "Cancelar": function () {
                            $(this).dialog("close");
                        }
                    }
                });
            return false;
        }
    </script>
</asp:Content>

